package org.example.common;

import lombok.Data;

import java.io.Serializable;

/**
 * Description: 通用返回结果
 * Author: Amao
 * Date: 2023/5/23
 */

@Data
public class CommonResult <T> implements Serializable {

        private Integer code;
        private String msg;
        private T data;

        public static <T> CommonResult<T> success(T data, String message) {
            CommonResult<T> result = new CommonResult<>();
            result.code = 200;
            result.data = data;
            result.msg = message;
            return result;
        }

        public static <T> CommonResult<T> error(Integer code, String message) {
            CommonResult<T> result = new CommonResult<>();
            result.code = code;
            result.msg = message;
            return result;
        }
}
